package SMUVE;

import SMUVE.*;

public class Player {
	private String name;
	private String room;
	private static final String delimiter = SMUVE.Msg_Pipe.delimiter;

	public Player(String n, String r) {
		name = n;
		room = r;
	}

	public String get_name() {
		return(name);
	}

	public String get_room() {
		return(room);
	}

	public void set_room(String room) {
		this.room = room;
	}

	public String toString() {
		return(name + delimiter + room);
	}

	public static Player fromString(String str) throws Exception {
		String[] res = str.split("\\" + delimiter);
		if (res.length < 3) // 1 + number of attributes in class
			throw (new InvalidMessageException("invalid Player"));
		return(new Player(res[1], res[2]));
	}
}
